package com.silverbox.waimai.mapper;

import java.util.Date;
import java.util.List;

import com.silverbox.sweeporder.controller.waimai.outvo.AllOrdersByShopVo;
import com.silverbox.waimai.entity.Waimai;
import org.apache.ibatis.annotations.Param;

import com.silverbox.waimai.entity.extend.WaimaiParam;
import com.silverbox.waimai.entity.extend.AlreadyGoods;
import com.silverbox.waimai.entity.extend.CopyGoods;
import com.silverbox.waimai.entity.extend.WaimaiExtend;

public interface WaimaiMapper {
    int deleteByPrimaryKey(Long id);

    int insert(Waimai record);

    int insertSelective(Waimai record);

    Waimai selectByPrimaryKey(Long id);

    int updateByPrimaryKeySelective(Waimai record);

    int updateByPrimaryKeyWithBLOBs(Waimai record);

    int updateByPrimaryKey(Waimai record);

	/**
	 * 根据订单号获取订单
	 * 
	 * @param orderNum
	 * @return
	 */
	Waimai getWaimaiByOrderNum(String orderNum);

	/**
	 * 根据订单号获取订单以及明细
	 * 
	 * @param orderNum
	 * @return
	 */
	WaimaiExtend getWaimaiAndDetailByOrderNum(String orderNum);

	/**
	 * 获取订单（根据桌台或者用户id）
	 * 
	 * @param waimaiParam
	 * @return
	 */
	Waimai getWaimai(WaimaiParam waimaiParam);

	/**
	 * 获取预订单
	 * 
	 * @param waimaiParam
	 * @return
	 */
	Waimai getPreparationWaimai(WaimaiParam waimaiParam);

	/**
	 * 获取订单以及明细
	 * 
	 * @param waimaiParam
	 * @return
	 */
	WaimaiExtend getWaimaiAndDetail(WaimaiParam waimaiParam);

	/**
	 * 获取历史订单以及明细
	 * 
	 * @param waimaiParam
	 * @return
	 */
	List<WaimaiExtend> getHistoryWaimaiList(WaimaiParam waimaiParam);

	/**
	 * 根据订单id更新订单项
	 * @param id
	 */
	void updateWaimaiItem(Long id);
	
	/**
	 * 批量删除订单
	 * @param ids
	 * @return
	 */
	void deleteOrderByIds(@Param("ids")List<String> ids);

	/**
	 * 获取仿菜
	 * @param storeId
	 * @param tableUid
	 * @param stareDate
	 * @param endDate
	 * @return
	 */
	List<CopyGoods> getCopyGoods(@Param("storeId")Integer storeId, @Param("tableUid")String tableUid, @Param("startDate")String startDate, @Param("endDate")String endDate);

	/**
	 * 根据订单号批量删除历史订单
	 * @param orderNum
	 */
	void deleteOrderByOrderNum(@Param("orderNums")List<String> orderNums);

	/**
	 * 删除订单项餐具费、打包费
	 * @param waimaiId
	 * @param barCode
	 * @return
	 */
	int deleteBagOrBoxItemByWaimaiId(@Param("waimaiId")Long waimaiId);

	/**
	 * 根据订单条件修改订单状态
	 * @param waimai
	 * @return
	 */
	int updateWaimaiByCleanTable(WaimaiParam waimai);

	/**
	 * 获取已点过的菜
	 * @param storeId
	 * @param buyerId
	 * @param creatDate
	 * @return
	 */
	List<AlreadyGoods> getAlreadyGoods(@Param("storeId") Integer storeId, @Param("thirdUserInfoId") Long thirdUserInfoId,
			@Param("createDate") String creatDate);
	
	/**
	 * 获取在线订单未核销订单
	 * @param param
	 * @return
	 */
	List<WaimaiExtend> getOnlineOrderHexiao(WaimaiParam param);

	/**
	 * 获取在线订单取餐柜订单
	 * @param param
	 * @return
	 */
	List<WaimaiExtend> getOnlineMealOrder(WaimaiParam param);

	/**
	 * 更新订单信息根据订单id或订单号
	 * @param param
	 * @return
	 */
	int updateWaimaiIdOrNum(WaimaiParam param);

	/**
	 * 根据订单号修改订单信息
	 * @param param
	 * @return
	 */
	int updateWaimaiByOrderNum(Waimai param);

	/**
	 * 根据取餐号获取订单
	 * @param param
	 * @return
	 */
	Waimai getWisdomOrderBySeq(WaimaiParam param);
	
	/**
	 * 获取当天在线订单未核销预约订单
	 * @param param
	 * @return
	 */
	List<WaimaiExtend> getTodayOrderHexiao(WaimaiParam param);
	
	List<WaimaiExtend> getTodayOrderHexiaoOrDelivery(WaimaiParam param);

	List<Waimai> getMyUnPayOrder( @Param("storeId")Integer storeId,  @Param("tableNum")String tableNum,  @Param("buyerId")String buyerId,  @Param("startDate")String startDate,  @Param("endDate")String endDate);

    List<AllOrdersByShopVo> findAllOrdersByShop(@Param("shopId") Long shopId, @Param("storeName") String storeName, @Param("outSupportId") Integer outSupportId, @Param("buyerIds") List<String> buyerIds, @Param("startTime") String startTime);

    int countAllOrdersByShop(@Param("shopId") Long shopId, @Param("storeName") String storeName, @Param("outSupportId") Integer outSupportId, @Param("buyerIds") List<String> buyerIds, @Param("startTime") String startTime);

    List<AllOrdersByShopVo> findAllOrders(@Param("storeName") String storeName, @Param("outSupportId") Integer outSupportId, @Param("buyerIds") List<String> buyerIds, @Param("startTime") String startTime);

    int countAllOrders(@Param("storeName") String storeName, @Param("outSupportId") Integer outSupportId, @Param("buyerIds") List<String> buyerIds, @Param("startTime") String startTime);

    List<WaimaiExtend> getWaimaiByBuyerIdInUnPaidEffective(@Param("buyerId") String buyerId,@Param("sevenDaysAgoTime") Date sevenDaysAgoTime);
}
